package pers.fengxu.learnmybatis.util;

public class CommUtil {
    public static String toBigCamelCase(String name) {
        if (name == null || name.trim().length() == 0) {
            return "";
        }
        name = name.toLowerCase();
        StringBuilder builder = new StringBuilder();
        char[] chars = name.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            if (chars[i] == '_') {
                continue;
            }
            if (i == 0 || chars[i - 1] == '_') {
                builder.append((char) (chars[i] ^ ' '));
            } else {
                builder.append(chars[i]);
            }
        }
        return builder.toString();
    }

    public static String toSmallCamelCase(String name) {
        if (name == null || name.trim().length() == 0) {
            return "";
        }
        name = toBigCamelCase(name);
        char[] chars = name.toCharArray();
        chars[0] ^= ' ';
        return new String(chars);
    }
}
